package nuc.jyg.util;

import nuc.jyg.entity.Appointment;

/**
 * @Author Nuc YongGuang Ji
 * Created by JiYongGuang on 2017/5/30.
 */
public enum AppointmentStateEnum {

    // 相当于 AppointmentStateEnum 类声明的一系列对象
    SUCCESS(1, "预约成功"), NO_NUMBER(0, "库存不足"), REPEAT_APPOINT(-1, "重复预约"), INNER_ERROR(-2, "系统异常");

    private int state;
    private String stateInfo;

    AppointmentStateEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    /**
     * Getter for property 'state'.
     *
     * @return Value for property 'state'.
     */
    public int getState() {
        return state;
    }

    /**
     * Getter for property 'stateInfo'.
     *
     * @return Value for property 'stateInfo'.
     */
    public String getStateInfo() {
        return stateInfo;
    }

    public static AppointmentStateEnum stateOf(int index) {
        for (AppointmentStateEnum state :
                values()) { // values() 方法对应于集合中声明的枚举类型变量的集合。 编译器加载的方法。看不到源码
            if (state.getState() == index)
                return state;
        }
        return null;
    }
}
